package com.genius.demo.rabbitmqconsumer.listener;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Map;

@Component
public class TopicTotalReceiver {
    @Autowired
    private ObjectMapper objectMapper;

    @RabbitListener(queues = "topic.woman")
    @RabbitHandler
    public void process(@Payload byte[] message) throws IOException {
        Map map = objectMapper.readValue(message, Map.class);
        System.out.println("TopicTotalReceiver消费者收到消息  : " + map.toString());
    }
}
